 <?php 
 defined('_JEXEC') or die('Restricted access');
 //print_r($this->data);die;
 //echo $_SESSION['id_a_b'];
 ?>

 <style>
.suggestionsBox {
		/*position: absolute;*/
		left: 30px;
		margin: 20px 0px 0px 0px;
		width: 200px;
		background-color: #212427;
		-moz-border-radius: 7px;
		-webkit-border-radius: 7px;
		border-radius: 4px;
		border: 2px solid #000;	
		color: #fff;
	}
	
	.suggestionList {
		margin: 0px;
		padding: 0px;
	}
	
	.suggestionList li {
		
		margin: 0px 0px 3px 0px;
		padding: 3px;
		cursor: pointer;
	}
	
	.suggestionList li:hover {
		background-color: #659CD8;}
</style>
<script type="text/javascript">
    $(function() {
        $( "#datepicker" ).datepicker();
    });
    function thong_ke()
    {
        window.location.href = "index.php?option=com_work_point&view=report";
        return;
    }
</script>
<script type="text/javascript">
	function lookup(manv) { //alert(manv);
		if(manv.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$.post("index.php?option=com_work_point&task=info_employee", {manv: ""+manv+""}, function(data){
				if(data.length >0) {
				    //alert(data);
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
	function fill(thisValue) {
        //alert(thisValue);
		$('#manv').val(thisValue);
                var x = $('#manv').val();
        
		setTimeout("$('#suggestions').hide();", 200);
                $.post("index.php?option=com_work_point&task=info_employee2", {manv: ""+x+""}, function(data){
                    
                    var ar = $.parseJSON(data);
                    $("#table_content").show();
                    $('#tenvn').text(ar.name);
                    $('#idnv').text(ar.id_em);
                    $('#id_use').val(ar.id);
                    $("#photonv").attr("src",'components/com_work_point/assets/images/'+ar.img);
			});
	}
    function kiem_tra()
    {
        if($('#manv').val()=='')
        {
            alert('Bạn chưa nhập mã nhân viên');
            return false;
        }
        return true;
    }
</script>
<input type="button" value="Thống kê chấm công" onclick="return thong_ke()" />
 <form method="post" action="index.php?option=com_work_point&task=save" onsubmit="return kiem_tra()">
    Mã NV:<input type="text" value="" id="manv" onkeyup="lookup(this.value);" name="manv" />
    <input type="hidden" name="id_use" id="id_use" />
            <div class="suggestionsBox" id="suggestions" style="display: none;" >
                                <div class="suggestionList" id="autoSuggestionsList">
                                
                                &nbsp;
                                
                                </div>
                                
                                </div><br />
    <br />
    <input type="radio" name="action" value="0" checked="check"  />Vào
    <input type="radio" name="action" value="1"/>Ra
<br />
<input type="submit" value="Gởi" />
 </form>
 <div style="float: right;">
     <table border="1" style="display:none;" id="table_content">
         <tr>
             <td rowspan="2"><img id="photonv" width="150" height="150" /></td>
             <td>Mã nhân viên:<span id="idnv"></span></td>
        </tr>
        <tr>
            <td>Tên nhân viên:<span id="tenvn"></span></td>
        </tr>
     </table>
 </div>
 
 <h1>Sử lược nhân viên ra vào</h1>
  <form method="post" action="index.php?option=com_work_point">
            <p>Date:<input type="text" id="datepicker" name="datepicker" value="<?php echo $this->date;?>"/>
            <input type="submit" value="Gửi" /></p></form>
 <table border="1">
    <tr>
        <td>
            Mã nhân viên
        </td>
        <td>
            Tên
        </td>
        <td>
            Trạng thái
        </td>
        <td>
            Thời gian
        </td>
    </tr>
    <?php
        if($_SESSION['id_a_b']==0)
        {
            foreach($this->data as $row)
            {
                if($row->id_a_b=='')
                {
                    ?>
                        <tr>
                            <td>
                                <?php echo $row->id_employee;?>
                            </td>
                            <td>
                                <?php echo $row->name;?>
                            </td>
                            <td>
                                <?php 
                                    if($row->type_in_out ==0)
                                        echo "Vào công ty";
                                    else
                                        echo "Rời công ty";
                                ?>
                            </td>
                            <td>
                                <?php echo $row->Time;?>
                            </td>
                        </tr>
                    <?php
                }
            }
        }
        else
        { 
            foreach($this->data as $row)
            {
                ?>
                    <tr>
                        <td>
                            <?php echo $row->id_employee;?>
                        </td>
                        <td>
                            <?php echo $row->name;?>
                        </td>
                        <td>
                            <?php 
                                if($row->type_in_out ==0)
                                    echo "Vào công ty";
                                else
                                    echo "Rời công ty";
                            ?>
                        </td>
                        <td>
                            <?php echo $row->Time;?>
                        </td>
                    </tr>
                <?php
            }
        }
    ?>
 </table>